@extends('home.login.layout')
@section('content')
<form action="{{url('/doReg')}}" method="post">    <div class="register">
        <div class="wrap">
            <div class="tabbable">
                <!-- tabs -->
                <ul class="nav-tabs">
                    <li id="tab2li" class="active"><a href="" data-toggle="tab">邮箱注册</a></li>
                </ul>
                @if (session('info'))
                        <span class="error" style="color:red;font-size:16px;text-align:center;">
                          <em>{{ session('info') }}</em>
                        </span>
                        @endif
                <div class="tab-content">
                    {{csrf_field()}}
                    <div class="tab-pane clearfix active" id="tab2">
                        <div class="fl">
                            <p>
                                <span class="field-name">邮箱</span>
                                <input class="input input-mail" id="email" name="email" placeholder="请输入您的邮箱" type="email" value="">
                                <span></span>
                            </p>
                            <p>
                                <span class="field-name">设置密码</span>
                                <input class="input input-keys" id="password" name="password" placeholder="6-20位字母、符号或数字" type="password">
                                <span></span>
                            </p>
                            <p>
                                <span class="field-name">确认密码</span>
                                <input class="input input-keys" id="repassword" name="repassword" placeholder="再次输入密码" type="password">
                                <span></span>
                            </p>
                           
                            <p>
                                <span class="field-name">手机号</span>
                                <input class="input input-keys" id="phone" name="phone" placeholder="手机号" type="text" value="">
                                <span></span>
                            </p>
                            <p>
                                <span class="field-name"></span><label><input type="checkbox" id="tab2chk">我已阅读并同意<a href="javascript:void(0)" class="green btn-protocol">《易果服务协议》</a><span></span></label>
                            </p>
                            <p><span class="field-name"></span><button class="btn-green-l" id="EmailReg">立即注册</button></p>
                        </div>
                        <div class="fr">
                        
                            
                        </div>
                    </div>
                </div>
                <div class="right">                    
                    我已经注册，现在就 <a class="orange" href="{{url('/login')}}">登录</a>
                    
                </div>
            </div>
        </div>
    </div>
</form>
<script type="text/javascript" src="{{url('/ad/plugins/jQuery/jQuery-2.1.4.min.js')}}"></script>
<script type="text/javascript">
    // 检测邮箱是否已注册
    $('#email').on('change',function(){
        var email = $(this).val();
        var span = $(this).next();
        $.ajax({
            type:"GET",
            url:"{{asset('/reg/ajax')}}",
            data:{email:email},
            success:function(data){
                if(data==2){
                    span.html('该邮箱已被注册，请<a style="color:blue;" href="{{url('/login')}}">登录</a> 或检查邮箱！！');
                    span.css({color:'red'});
                }else{
                    span.html('恭喜，该邮箱可以使用！！');
                    span.css({color:'green'});
                }
            },
            error:function(){
                alert('异常');
            }
        });    
    });
    $('#EmailReg').on('click',function(){
        // if(!$('#tab2chk').attr('checked')){
            
        //         alert('请阅读协议');
        //         return false;
        // }
    })
    // var inter = setInterval(function(){
    //     if(!$('#tab2chk').attr('checked')){
    //         $('#EmailReg').on('click',function(){
    //             // alert('请阅读协议');
    //             return false;
    //         });
    //     }
    // },1000);
    
</script>
@endsection